#include <bits/stdc++.h>
using namespace std;
int A1, B1, C1;
int A2, B2, C2;
int T1, T2, T3, T4, T5, T6, T7;
bool check(int t2, int t3, int t5) {
int xa0 = A1 - t2 - t3, xa1 = A2 - (T2 - t2) - (T3 - t3);
int xb0 = B1 - t2 - t5, xb1 = B2 - (T2 - t2) - (T5 - t5);
int xc0 = C1 - t3 - t5, xc1 = C2 - (T5 - t5) - (T3 - t3);
int L1 = max(0, T1 + T4 - xa1), R1 = xa0;
int L2 = max(0, T1 + T6 - xb1), R2 = xb0;
int L3 = max(0, T1 + T7 - xc1), R3 = xc0;
if(R1 < L1 || R2 < L2 || R3 < L3)return 0;
int t1 = min({T1, max({L1, L2, L3}), min({R1, R2, R3})});
int t4 = max(0, L1 - t1);
int t6 = max(0, L2 - t1);
int t7 = max(0, L3 - t1);
if (t1 + t4 <= R1 && t1 + t6 <= R2 && t1 + t7 <= R3 && t4 <= T4 && t6 <= T6 && t7 <= T7) {
cout << t1 << " " << t2 << " " << t3 << " " << t4 << " " << t5 << " " << t6 << " " << t7 << "\n";
return 1;
}
return 0;
}
void solve() {
cin >> A1 >> B1 >> C1;
cin >> A2 >> B2 >> C2;
cin >> T1 >> T2 >> T3 >> T4 >> T5 >> T6 >> T7;
for(int t2 = 0; t2 <= T2; t2++) {
for(int t3 = 0; t3 <= T3; t3++) {
for(int t5 = 0; t5 <= T5; t5++) {
if(check(t2, t3, t5))
return;
}
}
}
cout << -1 << "\n";
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t;
cin >> t;
while(t--) {
solve();
}
}
1529A - Eshag Loves Big Arrays | 19. Remove Nth Node From End of List |
925. Long Pressed Name | 1051. Height Checker |
695. Max Area of Island | 402. Remove K Digits |
97. Interleaving String | 543. Diameter of Binary Tree |
124. Binary Tree Maximum Path Sum | 1465. Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts |
501A - Contest | 160A- Twins |
752. Open the Lock | 1535A - Fair Playoff |
1538F - Interesting Function | 1920. Build Array from Permutation |
494. Target Sum | 797. All Paths From Source to Target |
1547B - Alphabetical Strings | 1550A - Find The Array |
118B - Present from Lena | 27A - Next Test |
785. Is Graph Bipartite | 90. Subsets II |
1560A - Dislike of Threes | 36. Valid Sudoku |
557. Reverse Words in a String III | 566. Reshape the Matrix |
167. Two Sum II - Input array is sorted | 387. First Unique Character in a String |